package com.wntms.yjj.dao;

import com.wntms.ft.pojo.User;
import com.wntms.yjj.pojo.Staff;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StaffManagerDao {
    @Insert("insert into staff_temp values(null,#{num},#{name},#{department},#{gender},#{salary},#{uid})")
    public Integer addC(Staff staff);
    @Insert("insert into user values(null,#{name},#{acount},#{password})")
    public Integer addU(@Param("name") String name,@Param("acount") String acount,@Param("password") String password);


    @Delete("delete from staff_temp where id=#{id}")
    public Integer deleteC(Integer id);
    @Delete("delete from user where id=#{uid}")
    public Integer deleteU(Integer uid);

    @Update("update staff_temp set name=#{name}, num=#{num},department=#{department},gender=#{gender},salary=#{salary} where id=#{id}")
    public Integer updateC(Staff staff);
    @Update("update user set name=#{name} where id=#{uid}")
    public Integer updateU(@Param("uid") Integer uid,@Param("name") String name);

    @Select("select *from user where name=#{name}")
    public User findUid(String name);

    @Select("select *from staff_temp")
    public List<Staff> findAll();

    @Select("select *from staff_temp where id=#{id}")
    public Staff findById(Integer id);

    @Select("select *from staff_temp where num=#{num}")
    public Staff findByNum(String num);

    @Select("select *from staff_temp where name=#{name}")
    public Staff findByName(String name);

    @Select("select *from staff_temp where department=#{department}")
    public List<Staff> findByDepartment(String department);

    @Insert("Insert into user_role values(null,#{uid},#{rid})")
    void setRid(@Param("uid") Integer uid,@Param("rid") Integer rid);
}
